<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\plan\model;

use app\common\model\Base;
use app\basic\model\Enterprise;
use app\duty\model\Events;
/**
 * 救灾执行管理
 */
class Record extends Base{
	

	protected $name = 'rescueexec';
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';
	
	public $planTypeList=[] ;

	public  function getType(){

	 $planType=db('basicinfo')->where(array('sysCode'=>20))->column('subsystemName','subsystemNo');
	 $this->planTypeList=$planType;
	 return $this->planTypeList;
	}



	public function gettypeIdAttr($value,$data){
		$this->getType();
		if($data['typeId']){
			return $this->planTypeList[$data['typeId']];
		}
		return null;
	}


	public function getExecTimeAttr($value,$data){
		if($data['execTime']){
			return date('Y-m-d H:i:s',$data['execTime']);
		}
	}

	public function setExecTimeAttr($data){

		if(is_numeric($data)){
			return time();
		}else{
			return strtotime($data);
		}
	}



	public function records(){
		return $this->hasMany('Recorddetail','rescueExecId','id');
	}


	public function events(){

		return $this->hasOne(Events::class,'id','eventId')->bind('title');

	}






}